package com.akw.boot3.core.service;

import com.akw.boot3.core.entity.UserEntity;
import com.akw.boot3.core.event.LoginSuccessEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

@Order(1)
@Service
public class SysService implements ApplicationListener<LoginSuccessEvent> {

    public void recordLog(String username) {
        System.out.println("记录登录日志：" + username);
    }

    @Override
    public void onApplicationEvent(LoginSuccessEvent event) {
        UserEntity source = (UserEntity) event.getSource();
        recordLog(source.getUsername());
    }
}
